#pragma once
#include <QWidget>
#include <QStylePainter>
#include <vector>
#include <bondlib/BondInfo.h>

class SVirtualTable;
class DefaultTableModel;
class STableColumnSet;

class InterestRateBondList : public QWidget
{
public:
	InterestRateBondList(QWidget* p);
	enum emCol {
		fuCol_ISSUEDATE = 0,		//发行日
		fuCol_NAME,					//债券简称
		fuCol_TERM,					//期限
		fuCol_ISSUE_AMOUNT,			//发行量
		fuCol_AUCTION_TIME,			//招标时间
		fuCol_ISSUE_RATE,			//加权利率
		fuCol_MARGINAL_RATE,		//边际利率
		fuCol_TOTAL_MULTIPLIER,		//全场倍数
		fuCol_MARGINAL_MULTIPLIER,	//边际倍数
		fuCol_SETTLEMENT_DATE,		//缴款日
		fuCol_LISTING_DATE,			//上市日
		fuCol_HISTORY_ISSUE,		//历史发行
		fuCol_MAX_COUNT
	};
	void setBondIndexs(const std::vector<int>& bondIndexs);

private:
	void initTable();
	void Sort();
	void updateTable(bool reset);
	bool GetLastAddIssue(const CBondInfo& bi, double& amount, int& noAddIssue);

private:
	SVirtualTable* m_table;
	STableColumnSet* m_tableSet;
	DefaultTableModel* m_model;
	std::vector<emCol> m_cols;
	std::vector<int> m_bondIndexs;
};